package com.woniuxy.oldmanapi.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.oldmanapi.entity.OlderWeight;
import com.woniuxy.oldmanapi.mapper.OlderWeightMapper;
import com.woniuxy.oldmanapi.vo.HeightVo;
import com.woniuxy.oldmanapi.vo.WeightVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WeightService {

    @Autowired
    OlderWeightMapper olderWeightMapper ;

    public PageInfo<WeightVo> findWeightByPage(Integer now, Integer size, String name) {
        PageHelper.startPage(now,size);
        List<WeightVo> weightVoList =  olderWeightMapper.selectWeightByName(name);
        return new PageInfo<>(weightVoList);
    }

    public void add(OlderWeight olderWeight) {
        olderWeightMapper.insert(olderWeight);
    }

    public void delete(int id) {
        olderWeightMapper.deleteByPrimaryKey(id);
    }

    public void modify(OlderWeight olderWeight) {
        olderWeightMapper.updateByPrimaryKey(olderWeight);
    }
    public WeightVo selectOne(int id) {
        return olderWeightMapper.selectOneByName(id);
    }
}
